package heven.holt.wan.android.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint
import heven.holt.library.base.BaseFragment
import heven.holt.wan.android.R
import heven.holt.library.adapter.CommonViewPagerAdapter
import heven.holt.wan.android.databinding.FragmentNavigationBinding

@AndroidEntryPoint
class NavigationFragment : BaseFragment<FragmentNavigationBinding>() {

    private val tabTexts by lazy { resources.getStringArray(R.array.navigation_tab_name) }

    override fun bindViewBinding(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): FragmentNavigationBinding = FragmentNavigationBinding.inflate(inflater, container, false)

    override fun initView() {
        initTabLayoutViewPager()
    }

    private fun initTabLayoutViewPager() {
        binding.viewPager.adapter = CommonViewPagerAdapter(
            this, listOf(
                NavigationLinkFragment(),
                NavigationSystemFragment()
            )
        )
        TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
            tab.text = tabTexts[position]
        }.attach()
    }

    override fun initData() {
    }
}